﻿using System;
using System.Data;
using Litografia.BusinessEntities;
using Microsoft.Practices.EnterpriseLibrary.Data;

[assembly: CLSCompliant(false)]
namespace Litografia.DataObjects
{
    public class DOBase
    {
        #region Declarations

        private static Database Db;
        private const string ColumnaId = "id";
        private const string ColumnaNombre = "nombre";
        
        #endregion

        #region Properties: Non-Public

        protected static Database DB
        {
            get
            {
                if (Db == null)
                    Db = DatabaseFactory.CreateDatabase();
                return Db;
            }
        }

        protected static BEEntity CreateEntityFromDataRow(DataRow row)
        {
            var entidad = new BEEntity
            {
                Id = row[ColumnaId].ToString(),
                Nombre = row[ColumnaNombre].ToString()
            };
            return entidad;
        }

        #endregion
    }
}
